/*
	This script file is part of the Sonic 3 A.I.R. script software distribution.
	Copyright (C) 2017-2024 by Eukaryot

	Published under the GNU GPLv3 open source software license, see license.txt
	or https://www.gnu.org/licenses/gpl-3.0.en.html
*/



//-------------------------------------------------------//
// Walk Into Level object                                //
//-------------------------------------------------------//

// This object makes the character walk in from outside at level start for certain levels
//  - CNZ1 and LRZ1 for Knuckles
//  - HPZ and DEZ1 for all characters

//# address-hook(0x044a0c) end(0x044a20)
function void fn044a0c()
{
	// This defines the position where to stop automatic moving right
	u16[A0 + 0x30] = u16[0xffffb000 + 0x10] + getScreenWidth() / 2 + 0x10
	objA0.value32 = u16[0xffffb000 + 0x14]

	objA0.update_address = 0x044a26
	fn044a26()
}


//# address-hook(0x044a26) end(0x044a62)
function void fn044a26()
{
	player1.control_override = 1
	control.player1 = 0x0800		// CONTROL_RIGHT, 0

	camera.use_forced_target = true			// Forces camera to a certain position
	camera.forced_target.x = u16[A0 + 0x30]
	camera.forced_target.y = objA0.value32

	D0.u16 = u16[0xffffb000 + 0x10] + 0x10
	if (D0.u16 < u16[A0 + 0x30])
		return

	player1.control_override = 0
	player2.control_override = 0
	UnloadObject()
}



